# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=latexila
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.18.1
pkgrel=1
arch=('any')
pkgdesc="LaTeX editor designed for the GNOME desktop (mingw-w64)"
options=(strip staticlibs)
depends=("${MINGW_PACKAGE_PREFIX}-gsettings-desktop-schemas"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-gtksourceview3"
         "${MINGW_PACKAGE_PREFIX}-gspell"
         "${MINGW_PACKAGE_PREFIX}-libgee")
makedepends=("${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
license=("GPL 2")
url="https://www.gnome.org"
install=${_realname}-${CARCH}.install
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        001-win.patch)
sha256sums=('edfd95f321dfff31fb094c243c358cb78d19904164b9ef4fb37c021113044d0a'
            '94159afb2c0f0688c375ddcce3bf7750e7179c40d394847c665bc492632e3942')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  patch -p1 -b -V simple -i ${srcdir}/001-win.patch

  autoreconf -sf
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  mkdir -p data/build_tools
  cp -rf ../${_realname}-${pkgver}/data/build_tools/* data/build_tools

  mkdir -p docs/reference/html
  cp -rf ../${_realname}-${pkgver}/docs/reference/html/* docs/reference/html

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
